package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.vo.hosp.DepartmentVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022/8/29 18:35
 */
@RestController
@RequestMapping("/admin/hosp/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value = "根据医院编号查询所有科室-树形")
    @GetMapping("/getDepartmentList/{hoscode}")
    public R getDepartmentList(@PathVariable("hoscode") String hoscode) {
        // 因为需要使用的是和前端树形组件对接的数据，所以使用的是Vo对象
        List<DepartmentVo> list = departmentService.getDepartmentList(hoscode);
        return R.ok().data("list", list);
    }
}
